import java.util.Scanner;

/**
 * @author: gao
 * @create-date: 2025/4/6 19:59
 */

public class Solution {
    int[] tmp;

    public int reversePairs(int[] nums) {
        int n = nums.length;
        tmp = new int[n];
        return Mergesort(nums, 0, n - 1);
    }

    private int Mergesort(int[] nums, int left, int right) {
        if (left >= right) return 0;
        int ret = 0;

        int mid = (left + right) / 2;
        ret += Mergesort(nums, left, mid);
        ret += Mergesort(nums, mid + 1, right);

        int p1 = left, p2 = mid + 1, i = left;
        while (p1 <= mid) {
            while (p2 <= right && nums[p2] >= nums[p1] / 2.0) p2++;
            if (p2 > right)
                break;
            ret += right - p2 + 1;
            p1++;
        }
        p1 = left;
        p2 = mid + 1;
        while (p1 <= mid && p2 <= right) {
            tmp[i++] = nums[p1] <= nums[p2] ? nums[p2++] : nums[p1++];
        }
        while (p1 <= mid) tmp[i++] = nums[p1++];
        while (p2 <= right) tmp[i++] = nums[p2++];
        for (int j = left; j <= right; j++) {
            nums[j] = tmp[j];
        }
        return ret;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextInt()) {
            int len = in.nextInt();
            int[] nums = new int[len];
            for (int i = 0; i < len; i++) {
                nums[i] = in.nextInt();
            }
            Solution solution = new Solution();
            System.out.println(solution.reversePairs(nums));
        }
    }
}